<?php

    class Object_groups_model extends MY_Model
    {
        
        var $objectgroups_groups = "SELECT 
            object_groups.object_type_ID, 
            groups.ID as group_ID,
            groups.name as group_name
            FROM object_groups
            LEFT JOIN groups ON object_groups.groups_ID = groups.ID
            ";
        
        function __construct()
        {
            parent::__construct();
            $this->table = 'object_groups';
        }

        function find_general_group($object_type_ID)
        {
            $q = $this->objectgroups_groups;
            $q .= "
            WHERE object_groups.object_type_ID = $object_type_ID
            AND groups.name = 'General' 
            ";

            $res = $this->db->query($q)->row_array();
            return $res;
        }
        
        function find_descriptions_groups($object_type_ID)
        {
            $q = $this->objectgroups_groups;
            $q .= "
            WHERE object_groups.object_type_ID = $object_type_ID
            AND groups.name != 'General' 
            ";

            $res = $this->db->query($q)->result_array();
            return $res;
        }
    }

?>
